package com.chenye.klock;

import org.springframework.boot.autoconfigure.klock.annotation.Klock;
import org.springframework.boot.autoconfigure.klock.annotation.KlockKey;
import org.springframework.stereotype.Component;

/**
 * @Auther:chenye
 * @Data:2018/4/13
 * @Description:
 */
//@KlockKey参数注解，意义和@Klock中的keys一样。
@Component
public class TestService {
    @Klock(keys = {"#name"})//spel表达式
    public void test(String name,@KlockKey Integer age){
        System.out.println("age="+age+"获取到锁");
        if("chenye".equals(name)){
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("name = "+name+"  age = "+age);
    }
}
